package com.yisu.expressway.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.yisu.expressway.R;
import com.yisu.expressway.model.CarIllegalInfo;


import java.util.ArrayList;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2016/10/26 0026.
 */

public class CarIllegalRecordAdapter extends  RecyclerView.Adapter<CarIllegalRecordAdapter.RecordViewHolder>  {

    ArrayList<CarIllegalInfo> mData = new ArrayList<>();
    private Context mContext;

    public CarIllegalRecordAdapter (Context context,ArrayList<CarIllegalInfo> list){
        this.mContext = context;
        mData = list;
    }

    @Override
    public RecordViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View mView = LayoutInflater.from(mContext).inflate(R.layout.illegal_record_item, parent, false);
        return new RecordViewHolder(mView);
    }

    @Override
    public void onBindViewHolder(RecordViewHolder holder, int position) {
        if(mData.size() <= position ){
            return;
        }

        final CarIllegalInfo info = mData.get(position);
        if(info != null){
            holder.mTv_time.setText(info.time);
            holder.mTv_address.setText(info.address);
            holder.mTv_reason.setText(info.reason);
            holder.mTv_money.setText(String.valueOf(info.money));
            holder.mTv_point.setText(String.valueOf(info.degree));
        }
    }

    @Override
    public int getItemCount() {
        return mData == null ? 0 : mData.size();
    }

    class RecordViewHolder extends RecyclerView.ViewHolder {

        @Bind(R.id.tv_illegal_time)
        TextView mTv_time;
        @Bind(R.id.tv_illegal_address)
        TextView mTv_address;
        @Bind(R.id.tv_reason)
        TextView mTv_reason;
        @Bind(R.id.tv_fine_money)
        TextView mTv_money;
        @Bind(R.id.tv_dock_point)
        TextView mTv_point;

        public RecordViewHolder(View itemView){
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
